package leetcode.offer;

/**
 * ClassName: Offer59I
 * Description:leetcode - 剑指offer 59 - I 滑动窗口的最大值
 * date: 2021-11-22 22:52
 *
 * @author liyifan
 */
public class Offer59I {
    public int[] maxSlidingWindow(int[] nums, int k) {
        if (nums == null || nums.length == 0)
            return new int[0];
        int[] res = new int[nums.length - k  + 1];
        int left = 0;
        int right = left + k - 1;
        while (right < nums.length) {
            int max = Integer.MIN_VALUE;
            for(int i = left;i <= right;i++) {
                max = Math.max(max, nums[i]);
            }
            res[left] = max;
            left++;
            right++;
        }
        return res;
        //todo:看高级做法
    }
}
